<template>
  <div>
    <nav-bar class="detailnav">
      <div class="detailleft" slot="left" @click="back">
        <img src="~assets/img/little-icon/back.png" alt="" />
      </div>
      <div slot="center" class="center">
        <div
          v-for="(item, index) in navtitle"
          :key="index"
          @click="clicktitle(index)"
          class="detailtitle"
          :class="{ active: currentindex == index }"
        >
          {{ item }}
        </div>
        <!-- <ul class="centertitle">
          <li
            v-for="(item, index) in navtitle"
            :key="index"
            @click="clicktitle(index)"
            class="title"
            :class="{ active: currentindex == index }"
          >
            {{ item }}
          </li>
        </ul> -->
      </div>
    </nav-bar>
  </div>
</template>

<script>
import NavBar from "../../../components/common/navbar/NavBar.vue";
export default {
  components: {
    NavBar,
  },
  data() {
    return {
      navtitle: ["商品", "参数", "评论", "推荐"],
      currentindex: 0,
    };
  },
  methods: {
    clicktitle(index) {
      this.currentindex = index;
      this.$emit("clicknav", index);
    },
    back() {
      this.$router.back();
    },
  },
};
</script>
<style scoped>
.center {
  display: flex;
  align-items: center;
}
.detailtitle {
  flex: 1;
  list-style: none;
}
.active {
  color: red;
}
.detailleft {
  display: flex;
  align-items: center;
}

.detailleft img {
  width: 25px;
  height: 25px;
  margin: 0 auto;
  margin-top: 13px;
  margin-left: 4px;
}
.detailnav {
  background-color: #fff;
}
</style>
